# Maintainer: Diego Sogari <diego.sogari@gmail.com>

_realname=soci
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.2.3
pkgrel=1
pkgdesc="SOCI - The C++ Database Access Library (mingw-w64)"
arch=('any')
url="http://soci.sourceforge.net/"
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-firebird2-git"
             "${MINGW_PACKAGE_PREFIX}-postgresql"
             "${MINGW_PACKAGE_PREFIX}-sqlite3")
depends=("${MINGW_PACKAGE_PREFIX}-boost")
optdepends=("${MINGW_PACKAGE_PREFIX}-firebird2-git"
            "${MINGW_PACKAGE_PREFIX}-postgresql"
            "${MINGW_PACKAGE_PREFIX}-sqlite3")
source=("${_realname}-${pkgver}.tar.gz::https://codeload.github.com/SOCI/soci/tar.gz/${pkgver}"
        "${_realname}-${pkgver}.patch")
sha256sums=('1166664d5d7c4552c4c2abf173f98fa4427fbb454930fd04de3a39782553199e'
            'd1fcdb5650cca8d947ee01af0cb65a72035bd5a8ea5bdb4669e45f52807ff6b1')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "../${_realname}-${pkgver}.patch"
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DSOCI_TESTS=OFF \
    "../${_realname}-${pkgver}/src"

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
